#pragma once

class Variable;

class CKeyboard final :
	public IEngMod,
	public IInput,
	public ICriticalSection
{
public:
	CKeyboard();
	~CKeyboard();

	/*-EngMod-------------------------------------------------------------------*/
	virtual void OnLoop(uint i) override;

	/*-IInput-------------------------------------------------------------------*/
	virtual bool GetKeyState(uint keyToCheck) const override;
	virtual void SetKeyState(uint keyToCheck, bool state) override;
	virtual void OnUpdate() override;

	/*--------------------------------------------------------------------------*/

	bool GetInputText(std::string& currentinput);
	void AddKeyboardDriver(IKeyboardDriver* ikd);

private:
	bool m_isShift;
	bool m_isAlt;
	bool m_isCtrl;
	uint m_currentTime;
	void TestKey(uint key, char lower, char upper, uint lockuntil);

	uchar* m_keyList;
	std::string m_inputContent;
	uint m_lockedUntil[SDLK_LAST];
	Variable* var_keyboard_inputrefresh;

	std::vector<IKeyboardDriver*> m_keyboardDrivers;
};

namespace sh
{
bool getkeystate(int key);
void setkeystate(int key, bool val);
};

extern CKeyboard* g_Keyboard;